package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Hotel;
import cn.wolfcode.trip.base.domain.Room;
import cn.wolfcode.trip.base.query.HotelQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IHotelService;
import cn.wolfcode.trip.base.service.IRoomService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("hotels")
public class HotelController {

    @Autowired
    private IHotelService service;

    @Autowired
    private IRoomService roomService;
    //查询状态为推荐的3条酒店信息,不分页
    @GetMapping("{state}")
    public List<Hotel> listCommendHotels(@PathVariable Integer state){
        List<Hotel> list= service.listCommendHotels(state);
        return list;

    }

    //根据酒店id查询酒店信息
    @GetMapping()
    public Hotel queryHotelById(Long id){
        Hotel hotel=service.queryHotelById(id);
        return hotel;
    }


    @GetMapping("{hotelId}/rooms")
    public List<Room> listRoomByHotleId(@PathVariable Long hotelId){
        List<Room> rooms= roomService.listRoomByHotleId(hotelId);
        return rooms;
    }


   //搜索酒店信息
    @GetMapping("/temp/temps")
    public PageInfo queryHotels(HotelQueryObject qo){
        qo.setPageSize(10);
        PageInfo info = service.query(qo);
        return info;
    }
}
